﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.RB
{
    class Class7
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            string s = ppa.PolicyActing.Policy.SelectedColRateFactors["祝寿金领取年龄"];

            int a=int.Parse(s.Substring(0,2));

            if(ppa.Period % 3==0 && ppa.Period>0 && ppa.Age<a)
            {
                da.Value = ppa.Amount * 0.15;
            }
            else if (ppa.Age >= a)
            {
                da.Value = ppa.Amount * 0.6;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            string s = ppa.PolicyActing.Policy.SelectedColRateFactors["祝寿金领取年龄"];

            int a = int.Parse(s.Substring(0, 2));

            if (ppa.Age == a)
            {
                da.Value = ppa.TotalFee;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            string s = ppa.PolicyActing.Policy.SelectedColRateFactors["祝寿金领取年龄"];

            int a = int.Parse(s.Substring(0, 2));

            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                if (ppa.Period == 0)
                {
                    da.Value = ppa.TotalFee;
                }
                else if(ppa.Age < a)
                {
                    da.Value = ppa.Amount * 2 + ppa.TotalFee;
                }
                else if (ppa.Age >= a)
                {
                    da.Value = ppa.Amount;
                }

                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {


            if (ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
            {
                string s = ppa.PolicyActing.Policy.SelectedColRateFactors["祝寿金领取年龄"];

                int a = int.Parse(s.Substring(0, 2));

                ppa.SchemePeriodActing.InsurantStates.Add("身故");

                if (ppa.Age < a)
                {
                    da.Value = ppa.Amount * 3;
                }

                ppa.IsCurrentFinish = true;
            }
        }
    }
}
